angular.module('starter.services', [])

    //本地数据库存储
    .factory('Storage', function() {
        return {
            set: function(key, data) {
                return window.localStorage.setItem(key, window.JSON.stringify(data));
            },
            get: function(key) {
                return window.JSON.parse(window.localStorage.getItem(key));
            },
            remove: function(key) {
                return window.localStorage.removeItem(key);
            }
        };
    })

    //聚焦
    .factory('$focus', function ($timeout, $window) {
        return {
            setFocus: function (id) {
                $timeout(function () {
                    var element = $window.document.getElementById(id);
                    if (element){
                        element.focus();
                    }
                });
            }
        }
    })

    //弹框
    .factory('$Dialog', function($ionicPopup){
        var service = {};
        // 触发一个按钮点击，或一些其他目标
        /*service.showPopup = function() {
         //$scope.data = {}

         // 一个精心制作的自定义弹窗
         var myPopup = $ionicPopup.show({
         template: '<input type="password" ng-model="data.wifi">',
         title: 'Enter Wi-Fi Password',
         subTitle: 'Please use normal things',
         scope: $scope,
         buttons: [
         { text: 'Cancel' },
         {
         text: '<b>Save</b>',
         type: 'button-positive',
         onTap: function(e) {
         if (!$scope.data.wifi) {
         //不允许用户关闭，除非他键入wifi密码
         e.preventDefault();
         } else {
         return $scope.data.wifi;
         }
         }
         },
         ]
         });
         myPopup.then(function(res) {
         console.log('Tapped!', res);
         });
         $timeout(function() {
         myPopup.close(); //由于某种原因3秒后关闭弹出
         }, 3000);*/

        // 一个确认对话框
        service.showConfirm = function(title, template) {
            return $ionicPopup.confirm({
                title: title,
                template: template,
                cancelText: '取消',
                okText: '确定'
            });
        };

        // 一个提示对话框
        /*$scope.showAlert = function() {
         var alertPopup = $ionicPopup.alert({
         title: 'Don\'t eat that!',
         template: 'It might taste good'
         });
         alertPopup.then(function(res) {
         console.log('Thank you for not eating my delicious ice cream cone');
         });
         };*/
        return service;
    })

    //百度地图
    .factory('$BaiduMap', function($rootScope) {
        var service = {};
        var res_position = [];
        service.getAddr = function() {
            var geolocation = new BMap.Geolocation();
            geolocation.getCurrentPosition(
                //获取位置信息成功
                function(position){
                    if(this.getStatus() == BMAP_STATUS_SUCCESS){
                        //console.log(JSON.stringify(position));
                        // 根据坐标得到地址描述
                        service.getGeo(position.point.lng, position.point.lat);
                    } else {
                        res_position = [];
                        $rootScope.$broadcast('BaiduMap.getLocationFailed');
                    }
                },{
                    // 指示浏览器获取高精度的位置，默认为false
                    enableHighAccuracy: true,
                    // 指定获取地理位置的超时时间，默认不限时，单位为毫秒
                    //          timeout: 5000,
                    // 最长有效期(30S)，在重复获取地理位置时，此参数指定多久再次获取位置
                    maximumAge: 30*1000
                });
        };

        service.getGeo = function(longitude, latitude) {
            var myGeo = new BMap.Geocoder();
            // 根据坐标得到地址描述
            myGeo.getLocation(new BMap.Point(longitude, latitude), function(result) {
                //console.log(longitude+','+latitude);
                //console.log(JSON.stringify(result));
                if (result) {
                    res_position = {
                        'address': result.address,
                        'province': result.addressComponents.province,
                        'city': result.addressComponents.city,
                        'country': result.addressComponents.district,
                        'location': result.point
                    };
                    console.log(JSON.stringify(res_position));
                    $rootScope.$broadcast('BaiduMap.getCurrentPosition');
                }else{
                    $rootScope.$broadcast('BaiduMap.getLocationFailed');
                }
            });
        };

        service.getAddrData = function () {
            return res_position;
        };

        return service;
    })

    //公共检查serice
    .factory('$ChkCommon', function($ionicLoading){
        var service = {};

        service.chkMobile = function (mobile) {
            var match_mobile = /^1[345678]\d{9}$/;
            if(!match_mobile.test(mobile)){
                $ionicLoading.show({
                    noBackdrop: true,
                    template: "亲，请输入正确的手机号",
                    duration: 1500
                });
                return false;
            }else{
                return true;
            }
        };

        service.chkPassword = function (password) {
            if(password.length < 6 || password.length > 18){
                $ionicLoading.show({
                    noBackdrop: true,
                    template: "亲，密码长度为6~18位哦",
                    duration: 1500
                });
                return false;
            }else{
                return true;
            }
        };

        service.chkPwdConfirm = function (pwd1, pwd2) {
            if(service.chkPassword(pwd1)){
                if(pwd1 != pwd2){
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: "亲，两次密码不一致",
                        duration: 1500
                    });
                }else{
                    return true;
                }
            }
            return false;
        };

        return service;
    })

    //验证码service
    .factory('$VerifyCode', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};

        var code_send = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/Customer/getVerifyCode',
                timeout: 2000
            }
        });

        //发送验证码
        service.sendCode = function(mobile) {
            return code_send.query({
                mobile: mobile,
                type: 4,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: "验证码发送成功",
                        duration: 2000
                    });
                }
                $rootScope.$broadcast('VerifyCode.sendCode');
            });
        };

        return service;
    })

    //用户注册
    .factory('$Register', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};
        var res_reg;

        var register = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/UserCenter/signUp',
                timeout: 2000
            }
        });

        //发送验证码
        service.signUp = function(mobile, code, password) {
            var md5_pass = hex_md5(password);
            var sha1_pass = hex_sha1(md5_pass);
            var split_pass = sha1_pass.split("").reverse().join("");
            var pay_pass = split_pass.toUpperCase();
            return register.query({
                device_id: 'h5',
                mobile: mobile,
                verify_code: code,
                password: pay_pass,
                channel_id: 'DAE2E932626F03016C149341FAE9E888A5687DB2',
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: "恭喜亲，注册成功",
                        duration: 2000
                    });
                    res_reg = r.data;
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                    res_reg = '';
                }
                $rootScope.$broadcast('Register.signUp');
            });
        };

        service.getResult = function () {
            return res_reg;
        };

        return service;
    })

    //用户登陆
    .factory('$Login', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};
        var res_log;

        var login = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/UserCenter/signIn',
                timeout: 2000
            }
        });

        //发送验证码
        service.signIn = function(mobile, password) {
            var md5_pass = hex_md5(password);
            var sha1_pass = hex_sha1(md5_pass);
            var split_pass = sha1_pass.split("").reverse().join("");
            var pay_pass = split_pass.toUpperCase();
            return login.query({
                mobile: mobile,
                password: pay_pass,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    res_log = r.data;
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                }
                $rootScope.$broadcast('Login.signIn');
            });
        };

        service.getResult = function () {
            return res_log;
        };

        return service;
    })

    //申请现金贷初始化页面
    .factory('$applyInit', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};
        var res_apply;

        var get_pd = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/WithdrawalsOrder/selWithdrawals',
                timeout: 2000
            }
        });

        //获取产品列表
        service.getProducts = function(init, uid) {
            return get_pd.query({
                init: init,
                customer_id: uid,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    res_apply = r;
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                }
                $rootScope.$broadcast('applyInit.getProducts');
            });
        };


        service.getResult = function () {
            return res_apply;
        };

        return service;
    })

    //用户认证初始化
    .factory('$authInit', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};
        var res_auth, res_status;

        var get_auth_info = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/Credit/getCustomerAuth',
                timeout: 2000
            }
        });

        var get_status = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/UserCenter/getCustomerWithdStatus',
                timeout: 2000
            }
        });

        //获取用户认证信息
        service.getAuthInfo = function(uid) {
            return get_auth_info.query({
                customer_id: uid,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0 || r.code == 229) {
                    res_auth = r;
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                }
                $rootScope.$broadcast('applyInit.getAuthInfo');
            });
        };

        //获取用户当前的现金贷信息
        service.getOrderStatus = function(uid) {
            return get_status.query({
                customer_id: uid,
                no_need_sign: true
            }, function(r) {
                if (r.code != 0) {
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                    return false;
                }else{
                    res_status = r.data;
                    $rootScope.$broadcast('apply.getOrderStatus');
                }
            });
        };

        service.getAuthData = function () {
            return res_auth;
        };

        service.getStatusData = function () {
            return res_status;
        };

        return service;
    })

    //保存用户身份信息
    .factory('$idNum', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};

        var idNum = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/Customer/saveIdCardInformation',
                timeout: 2000
            }
        });

        //保存身份证信息
        service.saveIdNum = function(user) {
            return idNum.query({
                customer_id: user.uid,
                id_num: user.id_num,
                real_name: user.name,
                type: 2,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: '哇，身份验证成功，亲离小钱钱就差一步之遥咯',
                        duration: 2000
                    });
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                    return false;
                }
                $rootScope.$broadcast('idNum.saveIdNum');
            });
        };

        return service;
    })

    //上传联系人信息
    .factory('$extroInfo', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};

        var extInfo = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/Credit/changeContactsInfo',
                timeout: 2000
            }
        });

        //保存身份证信息
        service.saveExtInfo = function(user) {
            return extInfo.query({
                customer_id: user.uid,
                wechat: user.wechat,
                user_address: user.user_address,
                company_name: user.company_name,
                company_phone: user.company_phone,
                parent_name: user.parent_name,
                parent_phone: user.parent_phone,
                parent_address: user.parent_address,
                friends_name: user.friends_name,
                friends_phone: user.friends_phone,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: '哇，联系人信息已保存，亲离小钱钱又近了一步哦',
                        duration: 2000
                    });
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                    return false;
                }
                $rootScope.$broadcast('extroInfo.saveExtInfo');
            });
        };

        return service;
    })

    //第三方认证
    .factory('$creditAuth', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};
        var auth_list_data;

        var auth_list = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/Credit/getAuthList',
                timeout: 2000
            }
        });

        //获取认证列表
        service.getAuthList = function(uid) {
            return auth_list.query({
                customer_id: uid,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    auth_list_data = r.data.auth_list;
                }else{
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                    return false;
                }
                $rootScope.$broadcast('creditAuth.getAuthList');
            });
        };

        service.getAuthRes = function () {
            return auth_list_data;
        };

        return service;
    })

    //设置支付密码
    .factory('$setPayPass', function($rootScope, $ionicLoading, $resource, ENV){
        var ApiUrl = ENV.api;
        var service = {};

        var set_paypass = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/Customer/setPayPass',
                timeout: 2000
            }
        });

        //设置支付密码
        service.setPayPass = function(uid, password) {
            var md5_pass = hex_md5(password);
            var sha1_pass = hex_sha1(md5_pass);
            var split_pass = sha1_pass.split("").reverse().join("");
            var pay_pass = split_pass.toUpperCase();
            return set_paypass.query({
                customer_id: uid,
                pay_pass: pay_pass,
                no_need_sign: true
            }, function(r) {
                if (r.code != 0) {
                    $ionicLoading.show({
                        noBackdrop: true,
                        template: r.msg,
                        duration: 2000
                    });
                    return false;
                }else{
                    $rootScope.$broadcast('setPayPass.setPayPass');
                }
            });
        };

        return service;
    })

    //现金贷申请
    .factory('$apply', function($rootScope, $resource, ENV) {
        var ApiUrl = ENV.api;
        var res_data, service = {};

        var apply_order = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/WithdrawalsOrder/withdrawalsApply',
                timeout: 2000
            }
        });

        //下单申请
        service.applyOrder = function(uid, pay_pass, amount, position) {
            return apply_order.query({
                customer_id: uid,
                province: position.province,
                city: position.city,
                country: position.country,
                address: position.address,
                location: position.location.lat+','+position.location.lng,
                pay_pass: pay_pass,
                apply_amount: amount,
                push_id: 'h5',
                black_box: 'h5',
                no_need_sign: true
            }, function(r) {
                res_data = r;
                $rootScope.$broadcast('apply.applyOrder');
            });
        };

        service.getRes = function () {
            return res_data;
        };

        return service;
    })

    //运营商认证
    .factory('$chmAuth', function($rootScope, $resource, $ionicLoading, ENV) {
        var ApiUrl = ENV.api;
        var res_data, service = {};

        var chm_auth_dhb = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/mobileCollect',
                timeout: 200000
            }
        });
        var chm_auth_jxl = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/mobileCollect2',
                timeout: 200000
            }
        });
        var chm_auth_lhp = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/mandateUser1',
                timeout: 200000
            }
        });

        //量化派认证
        service.chinaMobileLHP = function(mobile, chm_pwd, ch_captcha, ch_image, lhp_type, lhp_init) {
            var req_data = {};
            if(lhp_type == 0){
                req_data = {
                    mobile: mobile,
                    is_init: 0,
                    server_pass: chm_pwd,
                    no_need_sign: true
                };
            }else if(lhp_type == 1 || lhp_type == 2){
                if(lhp_init == 0){
                    chm_auth_lhp = $resource(ApiUrl, {}, {
                        query:{
                            method: 'post',
                            url: ApiUrl+'Home/CrawlerPost/mandateUser2',
                            timeout: 200000
                        }
                    });
                    req_data = {
                        mobile: mobile,
                        server_pass: chm_pwd,
                        type: lhp_type,
                        authCode: ch_image,
                        smsCode: ch_captcha,
                        no_need_sign: true
                    };
                }else if(lhp_init > 0){
                    chm_auth_lhp = $resource(ApiUrl, {}, {
                        query:{
                            method: 'post',
                            url: ApiUrl+'Home/CrawlerPost/mandateUser5',
                            timeout: 200000
                        }
                    });
                    req_data = {
                        mobile: mobile,
                        authCode: ch_image,
                        smsCode: ch_captcha,
                        no_need_sign: true
                    };
                }else{
                    res_data = {'code': -1};
                    $rootScope.$broadcast('chmAuth.chinaMobileLHP');
                    return false;
                }

            }

            return chm_auth_lhp.query(req_data, function(r) {
                res_data = r;
                if(r.code == 0 && r.type != 1 && r.type != 2){
                    alert('授权成功');
                }
                $rootScope.$broadcast('chmAuth.chinaMobileLHP');
            },function () {
                res_data = {'code': -1};
                $rootScope.$broadcast('chmAuth.chinaMobileLHP');
            });
        };

        //贷后绑认证
        service.chinaMobileDHB = function(mobile, chm_pwd, ch_captcha, ch_q_pwd, token, code, type) {
            var req_data = {
                mobile: mobile,
                password: chm_pwd,
                type: type,
                no_need_sign: true
            };
            if(code == ENV.captcha1 || code == ENV.captcha2){
                req_data = {
                    mobile: mobile,
                    captcha: ch_captcha,
                    token: token,
                    type: type,
                    no_need_sign: true
                };
            }else if(code == ENV.req_pwd){
                req_data = {
                    mobile: mobile,
                    query_password: ch_q_pwd,
                    token: token,
                    type: type,
                    no_need_sign: true
                };
            }
            return chm_auth_dhb.query(req_data, function(r) {
                res_data = r;
                if(r.code == 0){
                    alert('授权成功');
                }
                $rootScope.$broadcast('chmAuth.chinaMobileDHB');
            },function () {
                res_data = {'code': -1};
                $rootScope.$broadcast('chmAuth.chinaMobileDHB');
            });
        };

        //聚信力认证
        service.chinaMobileJXL = function(mobile, chm_pwd, ch_captcha, ch_q_pwd, token, code, website) {
            var req_data = {
                mobile: mobile,
                password: chm_pwd,
                no_need_sign: true
            };
            if(code == ENV.jxl_err_1 || code == ENV.jxl_err_2
                || code == ENV.jxl_err_3 || code == ENV.jxl_err_4){
                req_data = {
                    mobile: mobile,
                    captcha: ch_captcha,
                    password: chm_pwd,
                    website: website,
                    token: token,
                    no_need_sign: true
                };
            }else if(code == ENV.jxl_err_5){
                req_data = {
                    mobile: mobile,
                    captcha: ch_captcha,
                    password: chm_pwd,
                    query_password: ch_q_pwd,
                    website: website,
                    token: token,
                    no_need_sign: true
                };
            }
            return chm_auth_jxl.query(req_data, function(r) {
                res_data = r;
                if(r.code == 0){
                    alert('授权成功');
                }else{
                    alert(r.msg);
                }
                $rootScope.$broadcast('chmAuth.chinaMobileJXL');
            },function () {
                res_data = {'code': -1};
                alert('神马情况，是睡着了么？亲，再试一次吧');
                $rootScope.$broadcast('chmAuth.chinaMobileJXL');
            });
        };

        service.getRes = function () {
            return res_data;
        };

        return service;
    })

    //运营商服务密码重置
    .factory('$chmVerifyCode', function($rootScope, $resource, $ionicLoading, ENV) {
        var ApiUrl = ENV.api;
        var service = {}, res_data, res_code;

        var code_send_dhb = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/resetPasswordSend',
                timeout: 60000
            }
        });
        var code_send_jxl = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/resetPasswordSend2',
                timeout: 60000
            }
        });
        var reset_pwd_dhb = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/resetPassword',
                timeout: 120000
            }
        });
        var reset_pwd_jxl = $resource(ApiUrl, {}, {
            query:{
                method: 'post',
                url: ApiUrl+'Home/CrawlerPost/resetPassword2',
                timeout: 120000
            }
        });

        //发送验证码
        service.sendCode = function(mobile, type) {
            if(type == 1 || type == 2){
                service.sendCodeDHB(mobile, type);
            }else{
                service.sendCodeJXL(mobile);
            }
        };

        //贷后绑发送验证码
        service.sendCodeDHB = function(mobile, type) {
            return code_send_dhb.query({
                mobile: mobile,
                type: type,
                no_need_sign: true
            }, function(r) {
                if (r.code == 0) {
                    alert('验证码发送成功');
                    res_code = r;
                    $rootScope.$broadcast('chmVerifyCode.sendCodeDHB');
                }else{
                    //失败以后走聚信力重置密码
                    service.sendCodeJXL(mobile);
                }
            },function () {
                //失败以后走聚信力重置密码
                service.sendCodeJXL(mobile);
            });
        };

        //聚信力发送验证码
        service.sendCodeJXL = function(mobile) {
            return code_send_jxl.query({
                mobile: mobile,
                no_need_sign: true
            }, function(r) {
                res_code = r;
                if (r.code == 0) {
                    alert('验证码发送成功');
                }else{
                    alert(r.msg);
                }
                $rootScope.$broadcast('chmVerifyCode.sendCodeJXL');
            },function () {
                res_data = {'code': -1};
                alert('神马情况，是睡着了么？亲，再试一次吧');
                $rootScope.$broadcast('chmVerifyCode.sendCodeJXL');
            });
        };

        //运营商服务密码重置
        service.resetPWD = function(password, token, captcha, website) {
            var reset_pwd = reset_pwd_dhb;
            if(website.length > 0){
                reset_pwd = reset_pwd_jxl;
            }
            return reset_pwd.query({
                password: password,
                token: token,
                captcha: captcha,
                website: website,
                no_need_sign: true
            }, function(r) {
                res_data = r;
                if (r.code == 0) {
                    alert('重置成功');
                }else{
                    alert(r.msg);
                }
                $rootScope.$broadcast('chmVerifyCode.resetPWD');
            },function () {
                res_data = {'code': -1};
                alert('神马情况，是睡着了么？亲，再试一次吧');
                $rootScope.$broadcast('chmVerifyCode.resetPWD');
            });
        };

        service.getCode = function () {
            return res_code;
        };

        service.getResDate = function () {
            return res_data;
        };

        return service;
    })

    .factory('$sesame', function($rootScope, $resource, $ionicLoading, ENV) {
        var ApiUrl = ENV.api;
        var service = {}, res_data;

        //获取芝麻信用跳转的链接
        service.sesameAuth = function(id_num, name) {
            return $resource(ApiUrl, {}, {
                query:{
                    method: 'post',
                    url: ApiUrl+'Home/Zhima/ZhimaAuthInfoAuthorize',
                    timeout: 60000
                }
            }).query({
                id_num: id_num,
                name: name,
                no_need_sign: true
            }, function(r) {
                res_data = r;
                $rootScope.$broadcast('sesema_auth');
            },function () {
                res_data = {'code': -1, 'msg': '神马情况，是睡着了么？亲，再试一次吧'};
                $rootScope.$broadcast('sesema_auth');
            });
        };

        service.getResult = function () {
            return res_data;
        };

        return service;

    });
